package com.sbeam.controller;

import com.sbeam.service.SearchService;
import com.sbeam.vo.PageResult;
import com.sbeam.vo.SearchVO;
import com.sbeam.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/findByName")
    public SysResult findByName(PageResult pageResult){
        pageResult = searchService.findByName(pageResult);
        if (pageResult.getRows()==null){
            return SysResult.failed();
        }
        System.out.println(pageResult);
        return SysResult.success(pageResult);
    }

}
